import React, { Component } from 'react'
import { Button, Input, Row, Col, Select } from 'antd';
const { Option } = Select;
export default class searchDoctor extends Component {
    constructor(props) {
        super(props)
        this.state = {
            titles: ['主任', '副主任', '主治医师', '副主治医师', '实习医生'],
            offices: ['骨科', '内科', '外科', '妇科', '儿科', '脑科'],
            setName: '',
            setOffice: '',
            setTitle: ''
        }
    }
    handleChange = (dateType) => {
        return (event) => {
            console.log(dateType,event);
            if (event.target) {
                this.setState({[dateType]: event.target.value})
            }else{
                this.setState({[dateType]: event})
            }
            
            // console.log(this.state.setName,this.state.setOffice,this.state.setTitle);
        }
    }

    handleSearch = () => {
        console.log('上传的搜索数据：',this.state.setName,this.state.setOffice,this.state.setTitle);
        this.props.setSearch(this.state.setName,this.state.setOffice,this.state.setTitle)
    }

    handleInitialize = () => { 
        this.setState({
            setName: '',
            setOffice: '',
            setTitle: ''
        })
        setTimeout(() => {
            console.log(this.state.setName,this.state.setOffice,this.state.setTitle);
        }, 500);
        
    }
    render() {
        return (
            <div style={{ marginBottom: 20 }}>
                <Row>
                    <Col span={6}><Input value={this.state.setName} placeholder="请输入医生名称" onChange={this.handleChange('setName')} /></Col>
                    <Col span={6} offset={1}>
                        <Select value={this.state.setOffice} onChange={this.handleChange('setOffice')} style={{ width: 180 }}>
                            {this.state.offices.map((item, index) => {
                                return <Option value={item} key={index}>{item}</Option>
                            })}
                        </Select>
                    </Col>
                    <Col span={6} offset={1}>
                        <Select value={this.state.setTitle} onChange={this.handleChange('setTitle')} style={{ width: 180 }}>
                            {this.state.titles.map((item, index) => {
                                return <Option value={item} key={index}>{item}</Option>
                            })}
                        </Select>
                    </Col>
                    <Col>
                        <Button type="primary" onClick={this.handleSearch}>查询</Button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <Button onClick={this.handleInitialize}>重置</Button>
                    </Col>
                </Row>
            </div>
        )
    }
}
